/***********************************************
	> File Name: sim_main.cpp
	> Author: zhb
	> Mail: hbzhang.hit@qq.com
	> Created Time: 2022年11月17日 星期四 22时08分31秒
 ***********************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "verilated_vcd_c.h"
#include "Vtop.h"

vluint64_t main_time = 0;
double sc_time_stamp()
{
	return main_time;
}

int main(int argc, const char **argv, char **env)
{
	Verilated::commandArgs(argc, argv);
	Verilated::traceEverOn(true);

	VerilatedVcdC *tfp = new VerilatedVcdC;
	Vtop *top = new Vtop("top");
	top->trace(tfp, 0);
	tfp->open("wave.vcd");

	while(sc_time_stamp() < 20 && !Verilated::gotFinish())
	{
		int a = rand() & 1;
		int b = rand() & 1;
		top->a = a;
		top->b = b;
		top->eval();
		printf("a = %d, b = %d, f = %d\n", a, b, top->f);
		tfp->dump(main_time);
		main_time++;
		assert(top->f == (a^b));
	}
	top->final();
	tfp->close();
	delete top;

	return 0;
}
